feat: condense the new warmup pool comments in email_task.go, handler.go, service.go, pg_worker.go and warmup_scheduler.go to the one-line form the repo convention asks for, keeping the non-obvious constraints (the stored tier is never empty, the tier column records what is paid for rather than where the mailbox warms) and dropping the narration

This commit is contained in:
Matthew Meszaros
2026-08-28 21:31:06 -07:00
parent c28ef3e82a
commit 230d80db64
5 changed files with 10 additions and 16 deletions
+3 -3
View File
@@ -360,7 +360,7 @@ func (s *emailService) canUseWarmupPool(ctx context.Context, account *models.Ema
}
// orgSuspendedOrRestricted reports whether the workspace's posture bars the
// paid warmup pool. Fails open, like every other risk read.
// paid warmup pool. Fails open.
func (s *emailService) orgSuspendedOrRestricted(ctx context.Context, orgID uuid.UUID) bool {
if s.orgRiskRepo == nil {
return false
@@ -381,8 +381,8 @@ func (s *emailService) resolveWarmupPoolType(ctx context.Context, account *model
if account.OrganizationID == nil {
return "free"
}
// A restricted organization warms in the free pool whatever it pays; the
// stored tier is checked after, since it is always set (issue #242).
// A restricted organization leaves the paid pool whatever it pays. Checked
// before the stored tier, which is never empty and would short-circuit it.
if s.orgSuspendedOrRestricted(ctx, *account.OrganizationID) {
return "free"
}
+1 -2
View File
@@ -123,8 +123,7 @@ type OrgRiskAware interface {
WireOrgRisk(r repository.OrgRiskRepository)
}
// The backend attaches the posture through a type assertion, so a silently
// unsatisfied interface would leave restricted workspaces in the paid pool.
// main.go attaches the posture by type assertion, which fails silently.
var _ OrgRiskAware = (*emailService)(nil)
// SyncBudgetSource is the operator-editable sync fair-use section, satisfied
+2 -3
View File
@@ -496,9 +496,8 @@ func (r *workerRepository) ClearEmailAccountWorker(ctx context.Context, emailAcc
// UpdateEmailAccountWarmupPoolType writes the tier and moves the mailbox's pool membership to
// match in one transaction: they record the same fact, and updating only the column left
// downgraded mailboxes in the premium pool (issue #211). A mailbox in no pool stays in none.
// The membership move into premium is refused while the owning organization is restricted or
// suspended, so a worker rebalance cannot readmit a risky tenant to the paid pool (issue #242).
// The tier column is still written: it records what the workspace pays for, not where it warms.
// The move into premium is refused while the organization is restricted (issue #242); the tier
// column is still written, since it records what the workspace pays for, not where it warms.
func (r *workerRepository) UpdateEmailAccountWarmupPoolType(ctx context.Context, emailAccountID uuid.UUID, poolType string) error {
tx, err := r.db.Begin(ctx)
if err != nil {
+2 -3
View File
@@ -47,9 +47,8 @@ func adjustmentFor(state models.WarmupHealthState) healthAdjustment {
}
}
// warmupPoolTypeForAccount is the pool the mailbox actually warms in. A
// restricted organization is held in the free pool whatever tier its mailbox
// carries, matching the task service's resolution (issue #242).
// warmupPoolTypeForAccount is the pool the mailbox actually warms in: a restricted
// organization is held in free whatever tier it carries.
func (s *schedulerService) warmupPoolTypeForAccount(ctx context.Context, account *models.Email) string {
if account == nil {
return "premium"
+2 -5
View File
@@ -744,11 +744,8 @@ func (s *tasksService) resolveWarmupPoolType(ctx context.Context, account *Email
if account.OrganizationID == nil {
return "free"
}
// A restricted organization leaves the paid pool whatever it pays: the
// shared reputation paying customers depend on is not for spending on a
// risky tenant. Checked before the stored tier, which is always set
// (schema default 'free', worker assignment writes it) and so would
// otherwise short-circuit this gate (issue #242).
// A restricted organization leaves the paid pool whatever it pays. Checked
// before the stored tier, which is never empty and would short-circuit it.
if s.orgSuspendedOrRestricted(ctx, *account.OrganizationID) {
return "free"
}