From 50001fa52ebc96d8076c3ff07168d41fe290f450 Mon Sep 17 00:00:00 2001 From: Matthew Meszaros Date: Sun, 8 Nov 2026 14:37:56 +0100 Subject: [PATCH] feat: report workspace risk on a projected full-day hold, cap the iOS ramp start at the current ceiling, and pin the restricted ramp projection test to its expected three sends --- internal/scheduler/campaign_projection.go | 19 ++++++++++++------- internal/scheduler/warmup_graduation_test.go | 7 ++++++- .../Campaigns/CampaignSettingsPage.swift | 4 ++-- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/internal/scheduler/campaign_projection.go b/internal/scheduler/campaign_projection.go index 9feef9377..ac784e02d 100644 --- a/internal/scheduler/campaign_projection.go +++ b/internal/scheduler/campaign_projection.go @@ -139,6 +139,14 @@ type projectedSender struct { sentAll int } +// riskCut is what workspace risk takes from a cap, as stagedCap rounds it. +func (p *projectedSender) riskCut(c int) int { + if m := p.risk.CapMultiplier(); m < 1 { + return max(0, c-max(1, int(float64(c)*m+0.5))) + } + return 0 +} + // senderDay is one mailbox's day with the clamps that shaped it. type senderDay struct { sends, warmup int @@ -206,7 +214,8 @@ func projectSenderDay(p *projectedSender, spans []span, midnight, rampStart time c := p.cap if p.held { if p.heldTill == nil || !p.heldTill.Before(spans[len(spans)-1].to) { - d.held = c + d.risk = p.riskCut(c) + d.held = c - d.risk return d } spans = clipSpans(spans, *p.heldTill) @@ -229,12 +238,8 @@ func projectSenderDay(p *projectedSender, spans []span, midnight, rampStart time c = g } } - if m := p.risk.CapMultiplier(); m < 1 { - if r := max(1, int(float64(c)*m+0.5)); r < c { - d.risk = c - r - c = r - } - } + d.risk = p.riskCut(c) + c -= d.risk // The mailbox's own clock: a behaviour profile's workday, or the 8am-8pm // band in its own timezone when that differs from the campaign's. diff --git a/internal/scheduler/warmup_graduation_test.go b/internal/scheduler/warmup_graduation_test.go index 9f3e4e1ce..6c9038542 100644 --- a/internal/scheduler/warmup_graduation_test.go +++ b/internal/scheduler/warmup_graduation_test.go @@ -50,10 +50,15 @@ func TestProjectSenderDayAppliesTheCampaignRamp(t *testing.T) { } // Workspace risk cuts what the ramp left, as stagedCap does. p.risk = models.OrgRiskRestricted - want := max(1, int(10*p.risk.CapMultiplier()+0.5)) + want := 3 if d := projectSenderDay(p, spans, mid, day, false, 10); d.sends != want || d.ramp != 40 || d.risk != 10-want { t.Fatalf("restricted: got %+v, want %d sends after the ramp", d, want) } + // A held day still reports what risk would have taken. + p.cap, p.held = 40, true + if d := projectSenderDay(p, spans, mid, day, false, -1); d.sends != 0 || d.risk != 30 || d.held != 10 { + t.Fatalf("held and restricted: got %+v, want 30 to risk and 10 held", d) + } } func TestNextRampLevelStartsAtRampStart(t *testing.T) { diff --git a/ios/Warmbly/Features/Campaigns/CampaignSettingsPage.swift b/ios/Warmbly/Features/Campaigns/CampaignSettingsPage.swift index a9e49a31e..b5794d063 100644 --- a/ios/Warmbly/Features/Campaigns/CampaignSettingsPage.swift +++ b/ios/Warmbly/Features/Campaigns/CampaignSettingsPage.swift @@ -181,8 +181,8 @@ struct CampaignSettingsPage: View { ) if campaign.rampEnabled == true { stepperRow( - "Start", subtitle: "emails/day on day one", icon: "1.circle.fill", tone: .orange, - value: campaign.rampStart ?? 10, range: 1...5000, + "Start", subtitle: "emails/day on day one, up to the ceiling", icon: "1.circle.fill", tone: .orange, + value: campaign.rampStart ?? 10, range: 1...min(max(campaign.rampCeiling ?? 50, 1), 5000), body: { CampaignUpdateBody(rampStart: $0) }, mutate: { $0.rampStart = $1 } ) stepperRow(