Rotate CLI partners by sponsorship tier#486
Conversation
📝 WalkthroughWalkthroughPartner metadata and schema support were added across add-ons and hosts. The CLI now orders partner options by tier with deterministic seeded rotation, prioritizes Cloudflare for deployments, integrates ordering into prompts, and adds behavioral tests and package changesets. ChangesPartner placement
Estimated code review effort: 3 (Moderate) | ~20 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install failed: private package registry requires authentication. Disable ESLint in CodeRabbit settings or use public packages. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (3)
packages/cli/src/partner-placement.ts (2)
26-42: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winCorrect weighted-random ordering, but the math deserves a comment.
The seeded comparator correctly implements exponential-key weighted sampling (min-key variant of Efraimidis–Spirakis) for deterministic-but-rotating tie-breaking. It's mathematically sound, but non-obvious to a future reader without context.
📝 Suggested doc comment
+// Exponential-key weighted random ordering (Efraimidis–Spirakis, min-key +// variant): each item gets a fixed pseudo-random key derived from the seed +// and its id; smaller key sorts first, and higher `placementWeight` shrinks +// the key, making the item more likely to appear earlier. function compareSeededPartnerOrder(left: AddOn, right: AddOn, seed: string) {🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/cli/src/partner-placement.ts` around lines 26 - 42, Add a concise explanatory comment above compareSeededPartnerOrder documenting that it uses deterministic seeded exponential-key weighted sampling (the min-key Efraimidis–Spirakis variant), while preserving compareIdentity as the tie-breaker.
44-48: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winNarrow
surfaceto a literal union to catch typos at compile time.
surfaceis compared against the literal'deployment'internally (Line 61, 65), but its type is barestring. A typo at a call site (e.g. inui-prompts.ts) would silently skip the Cloudflare-first rule with no type error.♻️ Suggested type narrowing
+type PartnerPlacementSurface = 'add-ons' | 'deployment' + export function orderAddOnsForPartnerPlacement( addOns: Array<AddOn>, - surface: string, + surface: PartnerPlacementSurface, sessionSeed = cliSessionSeed, ) {🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/cli/src/partner-placement.ts` around lines 44 - 48, Update the surface parameter of orderAddOnsForPartnerPlacement to a literal union containing the supported surface values, including deployment, so invalid call-site strings fail at compile time while preserving the existing deployment comparison behavior.packages/cli/tests/partner-placement.test.ts (1)
39-55: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winNo test coverage for
placementWeight.
placementWeightdirectly affects the seeded comparator's key computation but is never exercised here — both fixtures use the default weight of1. A regression in the weight handling (e.g. inverted division) wouldn't be caught.Consider adding a case where one partner has a much larger
placementWeightand asserting it wins across a spread of seeds (or at least a specific seed where the effect is deterministic and verifiable).🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/cli/tests/partner-placement.test.ts` around lines 39 - 55, The test covering orderAddOnsForPartnerPlacement only uses the default placementWeight, so weighted comparator regressions are untested. Update the partners fixture to include a substantially different placementWeight and add assertions across representative CLI session seeds confirming the expected weighted ordering, while preserving the existing default-weight rotation coverage.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@packages/cli/src/partner-placement.ts`:
- Around line 26-42: Add a concise explanatory comment above
compareSeededPartnerOrder documenting that it uses deterministic seeded
exponential-key weighted sampling (the min-key Efraimidis–Spirakis variant),
while preserving compareIdentity as the tie-breaker.
- Around line 44-48: Update the surface parameter of
orderAddOnsForPartnerPlacement to a literal union containing the supported
surface values, including deployment, so invalid call-site strings fail at
compile time while preserving the existing deployment comparison behavior.
In `@packages/cli/tests/partner-placement.test.ts`:
- Around line 39-55: The test covering orderAddOnsForPartnerPlacement only uses
the default placementWeight, so weighted comparator regressions are untested.
Update the partners fixture to include a substantially different placementWeight
and add assertions across representative CLI session seeds confirming the
expected weighted ordering, while preserving the existing default-weight
rotation coverage.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 55c68efa-5aa1-451d-9273-1e03b1cc05c7
📒 Files selected for processing (16)
.changeset/fair-partner-placement.mdpackages/cli/src/partner-placement.tspackages/cli/src/ui-prompts.tspackages/cli/tests/partner-placement.test.tspackages/create/src/frameworks/react/add-ons/clerk/info.jsonpackages/create/src/frameworks/react/add-ons/prisma/info.jsonpackages/create/src/frameworks/react/add-ons/sentry/info.jsonpackages/create/src/frameworks/react/add-ons/workos/info.jsonpackages/create/src/frameworks/react/hosts/cloudflare/info.jsonpackages/create/src/frameworks/react/hosts/netlify/info.jsonpackages/create/src/frameworks/react/hosts/railway/info.jsonpackages/create/src/frameworks/solid/add-ons/sentry/info.jsonpackages/create/src/frameworks/solid/hosts/cloudflare/info.jsonpackages/create/src/frameworks/solid/hosts/netlify/info.jsonpackages/create/src/frameworks/solid/hosts/railway/info.jsonpackages/create/src/types.ts
Summary
Validation
Summary by CodeRabbit
New Features
Documentation