mirror of
https://github.com/warmbly/warmbly.git
synced 2026-11-17 08:18:51 +00:00
feat: hold the warmup reply share at the mailbox's reply rate by sending a reply only while one is due (warmupramp.ReplyDue) on both the arrival reply-back and the plain-send paths, at half again the target while due and never while ahead, so new threads refused by full recipient inboxes no longer push the seven-day share above the setting, with a simulation covering low new-thread reach and the warmup guide updated
This commit is contained in:
@@ -283,12 +283,14 @@ Replies thread properly with a real `Re:` subject and `In-Reply-To` header, and
|
||||
|
||||
The **Reply rate** setting targets the share of a mailbox's own warmup sends that are replies over its last seven UTC days. With enough eligible received mail, a mailbox set to `30%` approaches three replies for every ten warmup emails. The mailbox's **Reply target** card and the Analytics tab's **Replies** card both show the measured share over those same seven days, next to the target, and update as the mailbox sends and receives warmup mail. The reply count on the Analytics tab covers the last 30 days. Replies never add volume: each one takes the place of a send the mailbox was going to make anyway. `0%` turns replies off.
|
||||
|
||||
A reply is **due** when answering with the next send leaves the seven-day share no farther from the target than a new thread would. Both reply paths check this, so a mailbox ahead of its target sends no replies until new threads bring it back. When new threads cannot go out, for example because the pool's inboxes are at their daily receiving caps, the mailbox sends fewer warmup emails rather than more replies, and its share stays at the setting.
|
||||
|
||||
Replies reach that share two ways:
|
||||
|
||||
- **On arrival.** When a verified warmup email arrives, Warmbly includes the next send in its target calculation. If that leaves room for a reply, it sometimes points the next scheduled send back at whoever wrote, 45 minutes to 5 hours later and inside its own warmup hours. The chance is the mailbox's reply rate (raised for a sender in [recovery](#recovery-engagement)), drawn once when the reply is scheduled rather than again when it sends. Each mailbox has one warmup send queued at a time, so a reply-back moves that send earlier and aims it, and never pushes a send the mailbox had already planned sooner. If that send is due within 45 minutes of the arrival, or is already answering someone, the arrival is not answered then.
|
||||
- **When a send goes out.** Warmbly compares the mailbox's reply share over the last seven UTC days with its target and turns the difference into a reply chance for that send: the target itself when on track, more when behind and less when ahead, never more than one and a half times the target or less than half of it. For example, a `30%` target with no replies yet gives a `45%` chance, and one already replying to `80%` of its sends gives `15%`. A shortfall is made up over several days rather than in one burst of replies, and a mailbox ahead of its target keeps answering its conversations. A selected reply answers mail at least 45 minutes and at most seven days old that the mailbox has not answered. Mail from senders in [recovery](#recovery-engagement) is considered first, then replies in conversations already under way, deepest first, so replies build back-and-forth threads instead of answering many threads once; newest first breaks ties.
|
||||
- **On arrival.** When a verified warmup email arrives, Warmbly checks whether a reply is due. If it is, it sometimes points the next scheduled send back at whoever wrote, 45 minutes to 5 hours later and inside its own warmup hours. The chance is the mailbox's reply rate (raised for a sender in [recovery](#recovery-engagement)), drawn once when the reply is scheduled rather than again when it sends. Each mailbox has one warmup send queued at a time, so a reply-back moves that send earlier and aims it, and never pushes a send the mailbox had already planned sooner. If that send is due within 45 minutes of the arrival, or is already answering someone, the arrival is not answered then.
|
||||
- **When a send goes out.** While a reply is due, each send answers owed mail with a chance of one and a half times the target (capped at certain), and once none is due the chance is zero. For example, a `30%` target gives a `45%` chance while behind, and none once the mailbox is at `30%`. A shortfall is made up over several days rather than in one burst of replies. Mail the mailbox has not answered yet stays answerable for seven days, so a conversation paused while the mailbox is ahead can continue once a reply is due again. A selected reply answers mail at least 45 minutes and at most seven days old that the mailbox has not answered. Mail from senders in [recovery](#recovery-engagement) is considered first, then replies in conversations already under way, deepest first, so replies build back-and-forth threads instead of answering many threads once; newest first breaks ties.
|
||||
|
||||
Together these help the measured rate converge on the setting, including for busy mailboxes whose next send is almost always less than 45 minutes away. Small send counts and a recent setting change can make it differ temporarily. The rate can fall short when eligible received mail is unavailable, threads have reached their message caps, or the partners that wrote to it can no longer receive. Reply selection proceeds in batches with recovery priority, continuing past messages with unavailable content or partners until it finds a usable reply or exhausts the candidates.
|
||||
Together these hold the measured rate near the setting, including for busy mailboxes whose next send is almost always less than 45 minutes away and for mailboxes whose new threads often find no available recipient. Small send counts and a recent setting change can make it differ temporarily. The rate can fall short when eligible received mail is unavailable, threads have reached their message caps, or the partners that wrote to it can no longer receive. Reply selection proceeds in batches with recovery priority, continuing past messages with unavailable content or partners until it finds a usable reply or exhausts the candidates.
|
||||
|
||||
A reply is not held to the recipient's daily receiving cap and does not count against it. The cap limits new threads into an inbox; a reply answers mail that inbox sent, so its own sending already bounds how many replies it can get, and a free mailbox's replies never take the share of a paying inbox's day that is kept for premium senders. Replies stop before a thread reaches its message cap so replies cannot answer replies indefinitely. A reply crosses the free and paid tiers like the mail it answers: a paid mailbox answers a free partner that wrote to it, and a free mailbox answers a paid one while it is healthy and its workspace is in good standing.
|
||||
|
||||
|
||||
@@ -41,9 +41,9 @@ func (s *JobsService) scheduleWarmupReplyBack(ctx context.Context, token *models
|
||||
if !recipient.IsWarmingActive() {
|
||||
return nil
|
||||
}
|
||||
// Arrivals only spend the reply share the mailbox has left; a send it owes is repaid when its next plain send goes out.
|
||||
// Arrivals only answer while a reply is due, the same rule a plain send applies.
|
||||
if share, ok := s.TaskRepo.(repository.WarmupReplyShareRepository); ok {
|
||||
if sent, replied, err := share.WarmupReplyShare(ctx, recipientAccountID); err == nil && warmupramp.ReplyDeficit(recipient.WarmupReplyRate, sent, replied) <= 0 {
|
||||
if sent, replied, err := share.WarmupReplyShare(ctx, recipientAccountID); err == nil && !warmupramp.ReplyDue(recipient.WarmupReplyRate, sent, replied) {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,29 +13,20 @@ import (
|
||||
// ReplyShareWindowDays is how many UTC days of warmup sends a mailbox's reply share is read over.
|
||||
const ReplyShareWindowDays = 7
|
||||
|
||||
// ReplyDeficit is how many replies a mailbox owes, counting its next send, for
|
||||
// replies to be target percent of its warmup sends; zero or less is at or ahead.
|
||||
func ReplyDeficit(target, sent, replied int) float64 {
|
||||
// ReplyDue reports whether a reply as the next send leaves the share no farther from target than a new thread.
|
||||
func ReplyDue(target, sent, replied int) bool {
|
||||
if target <= 0 {
|
||||
return 0
|
||||
return false
|
||||
}
|
||||
return float64(min(target, 100))/100*float64(sent+1) - float64(replied)
|
||||
return float64(replied)+0.5 < float64(min(target, 100))/100*float64(sent+1)
|
||||
}
|
||||
|
||||
// ReplyChance is the chance the next plain send answers owed mail: the target
|
||||
// corrected by the window's drift, held within half the target either side so a
|
||||
// shortfall is repaid over days instead of in one burst of replies, and a
|
||||
// surplus slows replies without stopping conversations.
|
||||
// ReplyChance is the chance the next plain send answers owed mail: half again the target while a reply is due, else zero.
|
||||
func ReplyChance(target, sent, replied int) float64 {
|
||||
if target <= 0 {
|
||||
if !ReplyDue(target, sent, replied) {
|
||||
return 0
|
||||
}
|
||||
t := float64(min(target, 100)) / 100
|
||||
if sent <= 0 {
|
||||
return t
|
||||
}
|
||||
share := float64(replied) / float64(sent)
|
||||
return min(max(2*t-share, t/2), 1.5*t, 1)
|
||||
return min(1.5*float64(min(target, 100))/100, 1)
|
||||
}
|
||||
|
||||
// RecoverySignals are the reads that decide whether a sender gets recovery
|
||||
|
||||
@@ -6,22 +6,25 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestReplyDeficit(t *testing.T) {
|
||||
func TestReplyDue(t *testing.T) {
|
||||
for _, tc := range []struct {
|
||||
name string
|
||||
target, sent, replied int
|
||||
want float64
|
||||
want bool
|
||||
}{
|
||||
{"replies off", 0, 40, 0, 0},
|
||||
{"fresh mailbox owes a share of its first send", 30, 0, 0, 0.3},
|
||||
{"behind", 30, 19, 2, 4},
|
||||
{"on target", 50, 9, 5, 0},
|
||||
{"ahead", 30, 9, 6, -3},
|
||||
{"over 100 reads as 100", 150, 1, 0, 2},
|
||||
{"replies off", 0, 40, 0, false},
|
||||
{"a fresh mailbox's first send is a new thread", 30, 0, 0, false},
|
||||
{"a reply that lands closer to target is due", 30, 1, 0, true},
|
||||
{"behind", 30, 19, 2, true},
|
||||
{"one more reply would overshoot by more than it closes", 30, 10, 3, false},
|
||||
{"just under target", 30, 11, 3, true},
|
||||
{"ahead", 30, 9, 6, false},
|
||||
{"a full target always replies", 100, 10, 10, true},
|
||||
{"over 100 reads as 100", 150, 1, 1, true},
|
||||
} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
if got := ReplyDeficit(tc.target, tc.sent, tc.replied); math.Abs(got-tc.want) > 1e-9 {
|
||||
t.Fatalf("ReplyDeficit(%d,%d,%d)=%v, want %v", tc.target, tc.sent, tc.replied, got, tc.want)
|
||||
if got := ReplyDue(tc.target, tc.sent, tc.replied); got != tc.want {
|
||||
t.Fatalf("ReplyDue(%d,%d,%d)=%v, want %v", tc.target, tc.sent, tc.replied, got, tc.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -34,13 +37,13 @@ func TestReplyChance(t *testing.T) {
|
||||
want float64
|
||||
}{
|
||||
{"replies off", 0, 40, 0, 0},
|
||||
{"fresh mailbox replies at its target", 30, 0, 0, 0.3},
|
||||
{"on target", 30, 10, 3, 0.3},
|
||||
{"behind is repaid at up to half again the target", 30, 100, 0, 0.45},
|
||||
{"slightly behind leans toward replies", 30, 100, 20, 0.4},
|
||||
{"ahead still answers at half the target", 30, 100, 80, 0.15},
|
||||
{"a high target replies on a fresh mailbox", 80, 0, 0, 1},
|
||||
{"due is repaid at half again the target", 30, 100, 0, 0.45},
|
||||
{"just under target still repays at half again", 30, 11, 3, 0.45},
|
||||
{"ahead does not reply", 30, 100, 31, 0},
|
||||
{"one more reply would overshoot", 30, 10, 3, 0},
|
||||
{"never above certain", 80, 100, 0, 1},
|
||||
{"a high target still slows when ahead", 80, 100, 100, 0.6},
|
||||
{"a high target stops when ahead", 80, 100, 100, 0},
|
||||
{"over 100 reads as 100", 150, 10, 10, 1},
|
||||
} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
@@ -52,41 +55,47 @@ func TestReplyChance(t *testing.T) {
|
||||
}
|
||||
|
||||
// Over the same seven-day window the scheduler reads, the share settles on the
|
||||
// setting whether arrivals answer most of the owed mail or none of it, and a
|
||||
// window with no replies in it is repaid without any day turning into a burst.
|
||||
// setting whether arrivals answer most of the owed mail or none of it, and
|
||||
// whether a new thread always finds a recipient or mostly finds none (a pool
|
||||
// whose inboxes are at their daily caps refuses new threads but not replies).
|
||||
// A window with no replies in it is repaid without any day turning into a burst.
|
||||
func TestReplyShareConvergesWithoutBursts(t *testing.T) {
|
||||
const perDay, days = 30, 60
|
||||
const attemptsPerDay, days = 30, 60
|
||||
rng := rand.New(rand.NewSource(7))
|
||||
for _, target := range []int{10, 30, 60, 100} {
|
||||
for _, arrivalBinds := range []float64{0, 0.5, 0.9} {
|
||||
sent, replied := make([]int, days+7), make([]int, days+7)
|
||||
for i := range 7 {
|
||||
sent[i] = perDay
|
||||
}
|
||||
tail := 0.0
|
||||
for d := 7; d < days+7; d++ {
|
||||
for range perDay {
|
||||
s, r := 0, 0
|
||||
for k := d - 6; k <= d; k++ {
|
||||
s, r = s+sent[k], r+replied[k]
|
||||
for _, newThreadReach := range []float64{1, 0.5, 0.2} {
|
||||
sent, replied := make([]int, days+7), make([]int, days+7)
|
||||
for i := range 7 {
|
||||
sent[i] = attemptsPerDay
|
||||
}
|
||||
for d := 7; d < days+7; d++ {
|
||||
for range attemptsPerDay {
|
||||
s, r := 0, 0
|
||||
for k := d - 6; k <= d; k++ {
|
||||
s, r = s+sent[k], r+replied[k]
|
||||
}
|
||||
arrival := ReplyDue(target, s, r) && rng.Float64() < arrivalBinds*float64(target)/100
|
||||
switch {
|
||||
case arrival || rng.Float64() < ReplyChance(target, s, r):
|
||||
replied[d]++
|
||||
sent[d]++
|
||||
case rng.Float64() < newThreadReach:
|
||||
sent[d]++
|
||||
}
|
||||
}
|
||||
arrival := ReplyDeficit(target, s, r) > 0 && rng.Float64() < arrivalBinds*float64(target)/100
|
||||
if arrival || rng.Float64() < ReplyChance(target, s, r) {
|
||||
replied[d]++
|
||||
if day := float64(replied[d]) / attemptsPerDay * 100; target < 100 && day > min(2*float64(target)+12, 100) {
|
||||
t.Errorf("target %d%%, arrival binds %.0f%%, reach %.0f%%: day %d replied on %.0f%% of its attempts", target, arrivalBinds*100, newThreadReach*100, d, day)
|
||||
}
|
||||
sent[d]++
|
||||
}
|
||||
day := float64(replied[d]) / perDay * 100
|
||||
if limit := min(2*float64(target)+12, 100); target < 100 && day > limit {
|
||||
t.Errorf("target %d%% with arrival binds %.0f%%: day %d replied %.0f%% of its sends", target, arrivalBinds*100, d, day)
|
||||
s, r := 0, 0
|
||||
for k := days; k < days+7; k++ {
|
||||
s, r = s+sent[k], r+replied[k]
|
||||
}
|
||||
if d >= days {
|
||||
tail += day / 7
|
||||
if share := float64(r) / float64(s) * 100; math.Abs(share-float64(target)) > 3 {
|
||||
t.Errorf("target %d%%, arrival binds %.0f%%, reach %.0f%%: settled at %.1f%%", target, arrivalBinds*100, newThreadReach*100, share)
|
||||
}
|
||||
}
|
||||
if math.Abs(tail-float64(target)) > 5 {
|
||||
t.Errorf("target %d%% with arrival binds %.0f%%: settled at %.1f%%", target, arrivalBinds*100, tail)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user