Uh oh!
There was an error while loading. Please reload this page.
feat(core): add provider/adapter/display_name fields to ProviderKey (Phase A skeleton) - #298
Conversation
…Phase A skeleton) Second sub-PR of issue #302 Phase A. Pure type extension, zero behavior change. Adds four new fields to `ProviderKey`: - `provider: String` — vendor identity (free-form in this PR) - `adapter: Option<Adapter>` — wire-shape, pinned to the closed `Adapter` enum from #297 - `telemetry_tags: TelemetryTags` — attribution tags (kind / featured / branded_provider / pk_label / byo_label) All new fields use `#[serde(default)]` so legacy ProviderKey payloads that pre-date these fields keep deserializing. The JSON Schema gains matching optional properties with `additionalProperties: false` preserved end-to-end (`TelemetryTags` is also `deny_unknown_fields`). No dispatch path, snapshot loader, hub, bridge, or cp-api marshaller references the new fields in this PR. Follow-up Phase A sub-PRs wire them. `display_name` is unchanged (pre-existed on `ProviderKey`).
ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Free Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThis PR extends the ChangesProvider Key Phase A Extension
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Note 🎁 Summarized by CodeRabbit FreeYour organization has reached its limit of developer seats under the Pro Plan. For new users, CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please add seats to your subscription by visiting https://app.coderabbit.ai/login.If you believe this is a mistake and have available seats, please assign one to the pull request author through the subscription management page using the link above. Comment |
moonming
commented
May 16, 2026
Independent audit (CLAUDE.md §8)Cold re-read of the diff via FindingsHIGH — none. MEDIUM — none. LOW
Per-angle assessment
Merge gateNo HIGH or MEDIUM findings. The three LOW notes are documented for follow-up Phase A work and do not block merge. PASS — recommend merge after CI. |
moonming
commented
May 16, 2026
Independent third-party audit per CLAUDE.md §8 (separate from author self-review)Cold re-read of this PR by a fresh agent with no shared context with the implementation session or with the author's own audit comment above. Reviewed against the six required angles and against the canonical wire shapes in api7/AISIX-Cloud#302 §5. FindingsHIGH — none. MEDIUM — none. LOW
Per-angle assessment
Independent edge-case probe (not added to the PR — purely for audit verification, see findings above)Verified the following edge cases by spawning a temporary integration test in
Merge gateNo HIGH or MEDIUM findings. The three LOW notes are documented for follow-up Phase A work and do not block merge. PASS — recommend merge after CI. |
Uh oh!
There was an error while loading. Please reload this page.
Summary
Second sub-PR of api7/AISIX-Cloud#302 Phase A (DP-side Provider→Adapter refactor). Builds on #297 (which landed the
Adapterenum).This PR is intentionally zero-behavior-change — pure type extension on
ProviderKey. Nothing in the gateway reads the new fields yet;Providercontinues to drive 100% of dispatch.What this PR does
Adds four new fields to
aisix_core::ProviderKey:provider: String— vendor identity (e.g."deepseek","openai"). Free-formStringin this PR; closed-set validation is deferred to a later Phase A sub-PR that wires dispatch.adapter: Option<Adapter>— wire-shape, pinned to the closedAdapterenum from feat(core): add Adapter enum (skeleton for issue #302 Phase A) #297.Noneuntil a follow-up populates it.telemetry_tags: TelemetryTags— attribution tags emitted alongside requests routed through this key.Adds a new
TelemetryTagsstruct with five optional fields:kind: Option<String>— closed-set"catalog" | "byo"(enforced by the JSON Schema; the Rust type isOption<String>to stay forward-compatible if cp-api ships a new variant ahead of a DP rollout)featured: bool— defaults tofalsebranded_provider: Option<String>pk_label: Option<String>byo_label: Option<String>TelemetryTagsderivesDefaultand is#[serde(deny_unknown_fields)]so an unknown tag from cp-api fails loudly on the DP rather than silently dropping.Updates the
provider_keyJSON Schema with matching optional properties.additionalProperties: falseis preserved both at the top level and insidetelemetry_tags.adapteris constrained to the fiveAdapterenum values;kindis constrained to"catalog" | "byo".Re-exports
TelemetryTagsfromaisix_core::modelsand the crate root, mirroringAdapter.Backward compatibility
All four new struct fields use
#[serde(default)]. A pre-#302 payload like{"display_name":"openai-prod","secret":"sk-x","api_base":"https://api.openai.com/v1"}still deserializes —
providerlands as"",adapterasNone,telemetry_tagsasTelemetryTags::default(). A dedicated test pins this contract (legacy_payload_without_phase_a_fields_deserialises_with_defaults).The JSON Schema mirrors this: only
display_nameandsecretremain required.What this PR does NOT do
Providerdisplay_name(pre-existed onProviderKey)secret/api_basemustMarshalProviderKeyKVon the CP side (that's Phase D)rerank.rs(A5) orOpenAiBridge(A4)Design notes
Option<Adapter>overAdapter::Default: keepingadapterNone-able makes "Phase A hasn't backfilled this yet" representable. Adding a default variant would lie about adapter shape for un-tagged keys.TelemetryTagsas a struct (notHashMap<String, Value>): the catalog/byo attribution shape is a closed set known to both cp-api and the DP; a typed struct withdeny_unknown_fieldscatches drift between the two sides at parse time. A free-form map would silently swallow typos.Test plan
cargo test -p aisix-core— 150 passed, 0 failed (+14 over feat(core): add Adapter enum (skeleton for issue #302 Phase A) #297)cargo clippy --workspace --all-targets -- -D warnings— cleancargo fmt --all -- --check— cleanbranded_provider:null+byo_label) deserializesadapterstring rejected (closed-set guard)telemetry_tagsfield rejected (deny_unknown_fieldsguard)telemetry_tags.kindvalue rejected at schema layerReferences
Summary by CodeRabbit
New Features
Tests