-
Notifications
You must be signed in to change notification settings - Fork 0
Updated the scaling factors for domain warmup #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: coderabbit_combined_20260121_qodo_grep_cursor_copilot_base_updated_the_scaling_factors_for_domain_warmup_pr242
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -3,7 +3,7 @@ type LabsService = { | |||||||||
| }; | ||||||||||
|
|
||||||||||
| type EmailModel = { | ||||||||||
| findOne: (options: {filter: string; order: string}) => Promise<EmailRecord | null>; | ||||||||||
| findPage: (options: {filter: string; order: string; limit: number}) => Promise<{data: EmailRecord[]}>; | ||||||||||
| }; | ||||||||||
|
|
||||||||||
| type EmailRecord = { | ||||||||||
|
|
@@ -20,22 +20,48 @@ type WarmupScalingTable = { | |||||||||
| limit: number; | ||||||||||
| scale: number; | ||||||||||
| }[]; | ||||||||||
| defaultScale: number; | ||||||||||
| highVolume: { | ||||||||||
| threshold: number; | ||||||||||
| maxScale: number; | ||||||||||
| maxAbsoluteIncrease: number; | ||||||||||
| }; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| /** | ||||||||||
| * Configuration for domain warming email volume scaling. | ||||||||||
| * | ||||||||||
| * | Volume Range | Multiplier | | ||||||||||
| * |--------------|--------------------------------------------------| | ||||||||||
| * | ≤100 (base) | 200 messages | | ||||||||||
| * | 101 – 1k | 1.25× (conservative early ramp) | | ||||||||||
| * | 1k – 5k | 1.5× (moderate increase) | | ||||||||||
| * | 5k – 100k | 1.75× (faster ramp after proving deliverability) | | ||||||||||
| * | 100k – 400k | 2× | | ||||||||||
| * | 400k+ | min(1.2×, +75k) cap | | ||||||||||
| */ | ||||||||||
| const WARMUP_SCALING_TABLE: WarmupScalingTable = { | ||||||||||
| base: { | ||||||||||
| limit: 100, | ||||||||||
| value: 200 | ||||||||||
| }, | ||||||||||
| thresholds: [{ | ||||||||||
| limit: 1_000, | ||||||||||
| scale: 1.25 | ||||||||||
| }, { | ||||||||||
| limit: 5_000, | ||||||||||
| scale: 1.5 | ||||||||||
| }, { | ||||||||||
| limit: 100_000, | ||||||||||
| scale: 2 | ||||||||||
| scale: 1.75 | ||||||||||
| }, { | ||||||||||
| limit: 400_000, | ||||||||||
| scale: 1.5 | ||||||||||
| scale: 2 | ||||||||||
| }], | ||||||||||
| defaultScale: 1.25 | ||||||||||
| highVolume: { | ||||||||||
| threshold: 400_000, | ||||||||||
| maxScale: 1.2, | ||||||||||
| maxAbsoluteIncrease: 75_000 | ||||||||||
| } | ||||||||||
| }; | ||||||||||
|
|
||||||||||
| export class DomainWarmingService { | ||||||||||
|
|
@@ -72,17 +98,18 @@ export class DomainWarmingService { | |||||||||
| * @returns The highest number of messages sent from the CSD in a single email (excluding today) | ||||||||||
| */ | ||||||||||
| async #getHighestCount(): Promise<number> { | ||||||||||
| const email = await this.#emailModel.findOne({ | ||||||||||
| filter: `created_at:<${new Date().toISOString().split('T')[0]}`, | ||||||||||
| order: 'csd_email_count DESC' | ||||||||||
| const result = await this.#emailModel.findPage({ | ||||||||||
| filter: `created_at:<=${new Date().toISOString().split('T')[0]}`, | ||||||||||
| order: 'csd_email_count DESC', | ||||||||||
| limit: 1 | ||||||||||
| }); | ||||||||||
|
|
||||||||||
| if (!email) { | ||||||||||
| if (!result.data.length) { | ||||||||||
| return 0; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| const count = email.get('csd_email_count'); | ||||||||||
| return count || 0; | ||||||||||
| const count = result.data[0].get('csd_email_count'); | ||||||||||
| return count != null ? count : 0; | ||||||||||
|
Comment on lines
+111
to
+112
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix ESLint
🛠️ Proposed fix- const count = result.data[0].get('csd_email_count');
- return count != null ? count : 0;
+ const count = result.data[0].get('csd_email_count');
+ return count ?? 0;📝 Committable suggestion
Suggested change
🧰 Tools🪛 ESLint[error] 112-112: Expected '!==' and instead saw '!='. (eqeqeq) 🤖 Prompt for AI Agents |
||||||||||
| } | ||||||||||
|
|
||||||||||
| /** | ||||||||||
|
|
@@ -94,12 +121,20 @@ export class DomainWarmingService { | |||||||||
| return WARMUP_SCALING_TABLE.base.value; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| // For high volume senders (400k+), cap the increase at 20% or 75k absolute | ||||||||||
| if (lastCount >= WARMUP_SCALING_TABLE.highVolume.threshold) { | ||||||||||
| const scaledIncrease = Math.ceil(lastCount * WARMUP_SCALING_TABLE.highVolume.maxScale); | ||||||||||
| const absoluteIncrease = lastCount + WARMUP_SCALING_TABLE.highVolume.maxAbsoluteIncrease; | ||||||||||
| return Math.min(scaledIncrease, absoluteIncrease); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| for (const threshold of WARMUP_SCALING_TABLE.thresholds.sort((a, b) => a.limit - b.limit)) { | ||||||||||
| if (lastCount <= threshold.limit) { | ||||||||||
| if (lastCount < threshold.limit) { | ||||||||||
| return Math.ceil(lastCount * threshold.scale); | ||||||||||
| } | ||||||||||
| } | ||||||||||
|
|
||||||||||
| return Math.ceil(lastCount * WARMUP_SCALING_TABLE.defaultScale); | ||||||||||
| // This should not be reached given the thresholds cover all cases up to highVolume.threshold | ||||||||||
| return Math.ceil(lastCount * WARMUP_SCALING_TABLE.highVolume.maxScale); | ||||||||||
| } | ||||||||||
|
Comment on lines
+124
to
139
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Threshold boundaries push exact limits into the next band. With 🛠️ Proposed fix (inclusive upper bounds)- if (lastCount >= WARMUP_SCALING_TABLE.highVolume.threshold) {
+ if (lastCount > WARMUP_SCALING_TABLE.highVolume.threshold) {
const scaledIncrease = Math.ceil(lastCount * WARMUP_SCALING_TABLE.highVolume.maxScale);
const absoluteIncrease = lastCount + WARMUP_SCALING_TABLE.highVolume.maxAbsoluteIncrease;
return Math.min(scaledIncrease, absoluteIncrease);
}
for (const threshold of WARMUP_SCALING_TABLE.thresholds.sort((a, b) => a.limit - b.limit)) {
- if (lastCount < threshold.limit) {
+ if (lastCount <= threshold.limit) {
return Math.ceil(lastCount * threshold.scale);
}
}🤖 Prompt for AI Agents |
||||||||||
| } | ||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use
<to truly exclude today’s records.The method is documented as “excluding today,” and the unit test asserts a strict “before today” filter;
<=can include midnight records and fails that expectation.🛠️ Proposed fix
📝 Committable suggestion
🤖 Prompt for AI Agents