Skip to content

feat(keys): cross-provider model aggregation (stacked on #573) - #574

Open
guyu233 wants to merge 3 commits into
caigee-cmd:mainfrom
guyu233:feat/key-model-aggregation
Open

guyu233 wants to merge 3 commits into
caigee-cmd:mainfrom
guyu233:feat/key-model-aggregation

Conversation

@guyu233

@guyu233 guyu233 commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

上线前确认(必读)

必须由主仓维护者确认本次修复没有问题后,才能合并、上线或发布。
在获得主仓明确确认前,请保持 PR 为待审核状态,不要直接合并到 main 或进入 release。

Stacked on #573

This PR is stacked on top of #573 (feat/console-lazy-shell). The branch contains the two commits from #573 plus one aggregation commit:

  • perf(console): cut first-screen payload and request stats scans
  • test: keep the full suite green on Windows
  • feat(keys): add cross-provider model aggregation ← the only commit that belongs to this PR

Merge order: #573 first, then this PR. After #573 lands, rebase this branch onto main; GitHub will then show only the aggregation commit. Do not merge this PR before #573.

Summary

  • API keys gain model_aggregation. Existing keys default to false, so ordinary key behavior is unchanged.
  • An aggregation key's /v1/models returns only the public aliases its granted accounts define. Duplicate aliases from different providers/accounts are folded into one entry; entries omit provider, native_model, alias_of, regions, credits and free, and set owned_by: "aggregate".
  • Aggregation keys no longer add a provider prefix to model ids. executor.Prepare accepts only the bare aggregation alias for those keys; real model ids and provider-prefixed ids return 400 model_not_aggregated.
  • ResolveProviderFilter lets an aggregation key's bare alias search the full granted account pool.
  • No request fan-out / same-request_id merge was implemented; a single request still routes to one upstream account.
  • Key editor adds the “跨供应商模型聚合” switch and “聚合” badge; the modal now scrolls its provider list so save/cancel stay reachable on shorter screens.
  • Migration 030_api_key_model_aggregation.sql is new; shipped migration SQL bytes are untouched.

Verification

On the final PR head (which includes #573):

  • cd frontend && npm run lint — 0 errors (62 pre-existing warnings)
  • cd frontend && npm run build + node scripts/sync-static.mjs — pass; entry 422.55 kB / 134.97 kB gzip
  • go test ./... -count=1 -timeout 300s — pass (including migration 030 checksum, key CRUD round-trip, catalog aggregation and executor guards)
  • go vet ./... — pass
  • python scripts/release-notes.py validate — pass
  • Built the server and served the final embedded bundle on 127.0.0.1:3011; verified in the in-app browser: aggregation key card badge, edit modal switch state, save round-trip, scrollable modal footer, and no console errors.
  • New tests: TestExpandModelAliasesAddsPublicAlias, TestAggregateModelEntriesFoldsProviderAliases, TestPrepareAggregationKeyOnlyAcceptsItsAliases, plus API-key CRUD/store round-trips.

Risk / rollout

  • Routing change: aggregation keys intentionally reject native model ids and provider-prefixed ids. This is the core contract; verify with real granted accounts before release.
  • Catalog visibility: if an aggregation key has no visible accounts/aliases, /v1/models is empty by design.
  • Database: migration 030 adds one boolean column with a default; existing keys remain non-aggregating.
  • Merge gate: requires main-repo confirmation that the fix is correct before merge or release. Do not publish from this PR directly.

Rollback

Set the key's model_aggregation back to false (or revert migration 030 in a follow-up). The column default keeps old keys unaffected.

Closes no issue; follow-up to #573.

Lazy-load every console page, replace the shell's HeroUI controls with dependency-free primitives, load the update dialog on demand, and poll resources/live data less often. The embedded console now preloads only the entry, jsx-runtime and GSAP instead of the HeroUI shared chunk.

Also summarize request logs with one SELECT and aggregate in Go; the 20k-row local benchmark drops from ~227 ms to ~57 ms per call.
API keys can enable a provider-neutral model view. Aggregation keys only see the aliases their granted accounts define, with duplicate aliases folded into one entry, and may only call those names. Ordinary key behavior is unchanged.

Adds migration 030, key CRUD/settings plumbing, catalog aggregation, executor routing guards, key editor UI and bilingual notes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant