Conversation
🦋 Changeset detectedLatest commit: 4244d61 The changes in this PR will be included in the next version bump. This PR includes changesets to release 23 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
2 Skipped Deployments
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (12)
📝 WalkthroughWalkthroughImplements validation to prevent overlapping referral program editions for the same Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~30 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Greptile SummaryThis PR prevents overlapping referral program editions by introducing Confidence Score: 5/5Safe to merge — the core algorithm is correct, inclusive-bound semantics are consistent throughout, and address normalization via the existing Zod pipeline prevents key collisions in practice. All remaining findings are P2 style suggestions. The algorithm correctness is sound (sort + adjacent-pair scan is provably sufficient for detecting any overlap), inclusive-bound handling is consistent, and the test suite covers disjoint, interior-overlapping, abutting, cross-subregistry, and mixed-model cases. No files require special attention; the one P2 note on address casing in edition.ts is a defensive hardening suggestion only. Important Files Changed
Sequence DiagramsequenceDiagram
participant Caller
participant buildReferralProgramEditionConfigSet
participant validateNonOverlappingEditionTimes
participant findOverlappingEditionPair
participant ZodConfigSetArraySchema
participant ZodSummariesDataSchema
Caller->>buildReferralProgramEditionConfigSet: configs[]
buildReferralProgramEditionConfigSet->>buildReferralProgramEditionConfigSet: check duplicate slugs
buildReferralProgramEditionConfigSet->>validateNonOverlappingEditionTimes: configs[]
validateNonOverlappingEditionTimes->>findOverlappingEditionPair: configs[]
findOverlappingEditionPair->>findOverlappingEditionPair: group by subregistryId key
findOverlappingEditionPair->>findOverlappingEditionPair: sort each group by startTime
findOverlappingEditionPair->>findOverlappingEditionPair: adjacent-pair scan
findOverlappingEditionPair-->>validateNonOverlappingEditionTimes: [a,b] or null
validateNonOverlappingEditionTimes-->>buildReferralProgramEditionConfigSet: throws if overlap
buildReferralProgramEditionConfigSet-->>Caller: ReferralProgramEditionConfigSet
Note over ZodConfigSetArraySchema: Zod parse path
ZodConfigSetArraySchema->>findOverlappingEditionPair: result[]
findOverlappingEditionPair-->>ZodConfigSetArraySchema: [a,b] or null
ZodConfigSetArraySchema->>ZodConfigSetArraySchema: ctx.addIssue if overlap
Note over ZodSummariesDataSchema: Zod summary parse path
ZodSummariesDataSchema->>findOverlappingEditionPair: data.editions[]
findOverlappingEditionPair-->>ZodSummariesDataSchema: [a,b] or null
ZodSummariesDataSchema->>ZodSummariesDataSchema: ctx.addIssue if overlap
Reviews (1): Last reviewed commit: "Merge remote-tracking branch 'origin' in..." | Re-trigger Greptile |
There was a problem hiding this comment.
Pull request overview
Prevents a single referral from matching multiple referral program editions by enforcing a per-subregistryId time-range non-overlap invariant (with inclusive bounds), and refactors shared edition config fields/types to be reused across configs and summaries.
Changes:
- Introduces
BaseReferralProgramEditionConfigand uses it as a shared parent for edition configs and base edition summaries. - Adds
findOverlappingEditionPair/validateNonOverlappingEditionTimesand enforces the invariant in both config-set building and Zod parsing (including forward-compatible/unrecognized editions). - Adds/updates tests and fixtures to reflect inclusive-bound overlap behavior; exposes award-model Zod schemas via
@namehash/ens-referrals/internal.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| packages/ens-referrals/src/internal.ts | Re-exports per-award-model and shared Zod schemas via the internal entrypoint. |
| packages/ens-referrals/src/edition.ts | Adds shared base config type and overlap detection/validation; enforces invariant when building config sets. |
| packages/ens-referrals/src/edition.test.ts | New unit tests for overlap detection/validation and config-set building. |
| packages/ens-referrals/src/award-models/shared/edition-summary.ts | Refactors base summary to extend the shared base edition config type. |
| packages/ens-referrals/src/award-models/shared/api/zod-schemas.ts | Adds shared Zod schemas for edition slug and base edition config; reuses them in base summary schema. |
| packages/ens-referrals/src/api/zod-schemas.ts | Reuses shared schemas; enforces the non-overlap invariant in config-set array parsing and summaries response parsing. |
| packages/ens-referrals/src/api/zod-schemas.test.ts | Updates fixtures and adds test coverage for the non-overlap invariant (configs and summaries). |
| apps/ensapi/src/handlers/ensanalytics/ensanalytics-api.test.ts | Updates test setup to avoid summaries collapsing to overlapping windows by ensuring per-edition rules propagate into mock leaderboards. |
| .changeset/shiny-tigers-wander.md | Changeset for rejecting overlapping editions invariant. |
| .changeset/quiet-mirrors-shine.md | Changeset for exposing per-award-model Zod schemas via internal entrypoint. |
| .changeset/bright-rivers-flow.md | Changeset for adding BaseReferralProgramEditionConfig as a shared parent type. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Prevent overlapping referral program editions
closes: #1959
Summary
Why
Testing
Pre-Review Checklist (Blocking)