Files
magpie/internal/provider/codex_seals_test.go
T
yetone ac15036ab4 provider: a catalog entry points at its provider instead of copying it
Entry.Provider was a Provider value, 1,328 of an Entry's 1,760 bytes,
copied into every model of every provider each time a catalog, an
agent's list or a routing group's entries were built. It is now a
*Provider: entriesOf and decide's list give every model of one provider
the same one (sharedEntry), and a group's entry points at its first
member's. It is read only; every place that hands it on as a value
(Resolve, CanFast, ownAgent, modelAllowed, …) dereferences it, so what
they get is a copy as before. entryFor keeps its signature for the one
model ServedEntryOf builds; offEntries' entries now carry their provider
too.

Measured on mote with the owner's real accounts (acctp sandbox, page
open for 2m32s, w40 = before, w41 = this, alternating):
- catalogOf's allocations 106 MB -> 67 MB, providerEntries' 88 -> 78 MB
- CPU at the page's settle mark 3.42/3.33 s -> 3.18/3.30 s
- live heap unchanged (76.3/76.1 -> 76.7/75.9 MB): the lists are
  rebuilt, not kept, so the copies were churn for the GC, not held

Run: go build and go vet ./... and the tests compiled (go test -run ^$)
on mote; the full suite at this tree (d1e823d5f) on mica: 99 packages ok, 0 FAIL (agent 317s, gateway 972s, gui 188s, provider 220s, usage 56s).
2026-11-13 05:12:30 +08:00

39 lines
1.5 KiB
Go

package provider
import (
"testing"
"github.com/yetone/magpie/internal/catalog"
)
// A model seals a V2 lead's subagent tasks when its provider is of no
// sign-in on the Responses API (a relay of the ChatGPT backend, #1109), or
// a group has such a member; a chat-only key and another account
// (Copilot) seal none (brethhbbm on X).
func TestCodexSeals(t *testing.T) {
relay := Provider{ID: "relay", Chat: "https://relay.example/v1", Responses: "https://relay.example/v1"}
chat := Provider{ID: "ds", Chat: "https://api.deepseek.example/v1"}
copilot := Provider{ID: "copilot", Responses: "https://api.githubcopilot.example", Account: &Account{Agent: "copilot"}}
members := map[string][]Member{
"group/mixed": {{Provider: chat, Model: "deepseek-v4"}, {Provider: relay, Model: "gpt-6-astra"}},
"group/plain": {{Provider: chat, Model: "deepseek-v4"}, {Provider: copilot, Model: "gpt-6.1-sol"}},
}
of := func(id string) []Member { return members[id] }
for _, c := range []struct {
e Entry
want bool
}{
{Entry{ID: "relay/gpt-6-astra", Provider: &relay, Model: "gpt-6-astra"}, true},
{Entry{ID: "ds/deepseek-v4", Provider: &chat, Model: "deepseek-v4"}, false},
{Entry{ID: "copilot/gpt-6.1-sol", Provider: &copilot, Model: "gpt-6.1-sol"}, false},
{Entry{ID: "group/mixed", Group: "mixed"}, true},
{Entry{ID: "group/plain", Group: "plain"}, false},
} {
var m catalog.Model
CodexSeals(&m, c.e, of)
if m.Seals != c.want {
t.Errorf("%s: Seals %v, want %v", c.e.ID, m.Seals, c.want)
}
}
}