mirror of
https://github.com/warmbly/warmbly.git
synced 2026-09-06 16:01:28 +00:00
* feat: index advisor findings by subject and parent entity so a list page fetches its whole surface once and every row resolves its own advice from the shared cache instead of firing a request per row * feat: rebuild the advisor fix drawer as a three-screen resolution flow (why it fired with the measured evidence, the exact before and after, then an animated outcome with undo) with a progress rail and direction-aware transitions, and deep-link manual fixes to the screen where they are made * feat: add AdvisorRowFlag, the inline per-row advisor indicator that renders on the mailbox or campaign the problem is about and opens that row's findings in an anchored panel instead of making the reader join a card list against a table * feat: add AdvisorSummaryBar, a one-line collapsible page summary that replaces the stack of advisor cards above a list, counts the distinct rows implicated rather than the findings, and forces itself open only for critical or workspace-level advice no row flag can carry * feat: put advisor advice on the mailbox row it is about in the accounts list, replace the card stack above the table with the collapsible summary bar, and support ?mailbox=<id> so a finding can deep-link straight to the mailbox detail instead of the top of the list * feat: flag advisor findings on the campaign row in the campaigns list, including step-level copy problems which index onto their parent campaign since a step has no row of its own, and add the collapsible summary bar above the list * feat: move the deliverability and contacts pages onto the collapsible advisor summary bar so their findings stop pushing the numbers they describe below the fold * feat: add an ordered Steps field to advisor findings, persisted as text[] and always refreshed from the current build, and write real how-to steps for the deliverability checks that have no one-click fix (bounce rate, spam placement, tracking domain, and per-record SPF/DKIM/DMARC instructions) * feat: write ordered how-to steps for the manual advisor findings where the remedy alone leaves someone stuck (broken template syntax, missing first-name fallback, unsubscribed contacts still enrolled, a campaign with no resolvable sender, and a mailbox that lost warmup pool standing) and correct the personalization detail that named a merge syntax this product does not use * feat: show a mailbox's advisor findings at the top of its detail drawer, which is where both the row flag and the ?mailbox deep link now land * feat: open the resolution flow from findings that have no one-click fix too, since the ordered how-to lives there and a card with no Fix button previously left the steps unreachable * docs: document the per-row advisor flags, the collapsible page summary, the three-screen resolution flow, and the ordered manual steps for findings with no one-click fix * feat: align the advisor summary bar to the px-5 page gutter used by SectionBar and the list rows on all four surfaces, instead of sitting flush against the edge while the table it describes is indented * fix: stop the resolution drawer collapsing to zero height between screens by switching the step transition to popLayout with a layout-animated container, so the dialog resizes into the next screen instead of snapping shut and reopening * feat: wire the advisor repository, narrator, service, tool registration, and background runner into the backend boot path so findings evaluate on a schedule and the assistant can read them * docs: register the advisor guide in the sidebar, add its endpoint scope table to the API reference, and document the sandbox advisor showcase * fix: darken the advisor nav badge to solid orange-600 on white instead of a pale amber-100 chip that read as a disabled control beside the sidebar's saturated indicators, and drop the critical badge to rose-600 so the two stay in the same weight class * fix: use orange-500 for the advisor nav badge, matching the high-severity dot on the row it points at, rather than the darker orange-600 * feat: add an Auto safety class to advisor actions and mark the seven fixes autopilot may apply unattended (the cap cuts, the send-gap widen, the campaign limit matches, and the unsubscribe header), with a test pinning the boundary so nothing that halts sending or generates new outbound mail can drift into it * feat: add advisor autopilot, which applies the auto-safe fixes unattended as the member who switched it on, resolving their live permissions each run so it fails closed when they leave the org, bounded to 10 changes per evaluation and audited per fix like any hand-made change * feat: add the advisor agent fix, a bounded per-finding agent run that resolves the problems a settings change cannot (broken template syntax, bulk-reading copy, shared-inbox lists) as the calling member inside a tool allowlist scoped to the finding's category, metered per iteration and marked applied only when it actually called a write tool * feat: surface autopilot and the agent fix in the dashboard, adding the workspace toggle that names exactly which changes it may make, an Auto chip on the findings it is allowed to take, and an agent-fix path in the resolution drawer that reports the tools it actually called rather than only its own account of them * docs: document the agent fix and autopilot, naming the exact set of changes autopilot may make, that it acts as the member who enabled it and stops when they leave, and why the agent-fix endpoint is JWT only * fix: gate the agent fix per detector instead of per category, so a missing DMARC record no longer offers a Fix-with-agent button it can never satisfy and then reports failure; findings whose fix lives in DNS or a provider console now show their manual steps, and the client is told which is which via agent_fixable * feat: soften the advisor surfaces to translucent washes, replacing the filled nav badge with a tinted pill that carries its colour in the text, frosting the row panel and the resolution drawer, and turning the severity chips and cards into layers the page shows through * docs: correct the agent-fix scope to name the findings it cannot resolve, and why a DNS record shows steps instead of a button * feat: ship the actual DNS records for the findings that live outside the platform, with the provider's SPF include resolved, the DMARC record scoped to the sending domain and starting at p=none, the DKIM host plus the console that generates its value, and a tracking CNAME pointing at this install's own tracking host * feat: render advisor snippets as labelled copy-button rows so a DNS record is one click per field rather than a text-selection exercise, with no copy affordance on a value the server could not supply * docs: document the pasteable DNS records and the guarantee that every check offers a fix, an agent, or ordered steps * fix: bump golang.org/x/text to 0.39.0 to clear CVE-2026-56852, a HIGH-severity infinite loop in norm.Iter that Trivy started failing the security scan on
319 lines
13 KiB
Go
319 lines
13 KiB
Go
package advisor
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/warmbly/warmbly/internal/models"
|
|
"github.com/warmbly/warmbly/internal/repository"
|
|
)
|
|
|
|
// listDetectors read the audience rather than the message. Most campaign
|
|
// failures are list failures wearing a copy costume, so these matter more than
|
|
// their severity suggests.
|
|
func listDetectors() []Detector {
|
|
return []Detector{
|
|
{
|
|
Key: "list_role_addresses",
|
|
Category: models.AdvisorCategoryList,
|
|
About: "The share of a campaign's audience that is a shared inbox (info@, sales@, support@). These rarely reply, are frequently monitored by people with no interest in the offer, and complain at a higher rate than named recipients.",
|
|
Run: detectRoleAddresses,
|
|
},
|
|
{
|
|
Key: "list_free_mail_heavy",
|
|
Category: models.AdvisorCategoryList,
|
|
About: "The share of a B2B campaign's audience on consumer mailbox domains. A cold list that is mostly consumer addresses is usually scraped rather than sourced, and both reply and complaint rates reflect that.",
|
|
Run: detectFreeMailHeavy,
|
|
},
|
|
{
|
|
Key: "list_suppressed_share",
|
|
Category: models.AdvisorCategoryList,
|
|
About: "Leads already on the organization's suppression list. They are skipped at send time, so a large share means the campaign delivers far less than its numbers suggest.",
|
|
Run: detectSuppressedShare,
|
|
},
|
|
{
|
|
Key: "list_missing_personalization_data",
|
|
Category: models.AdvisorCategoryList,
|
|
About: "Contacts missing the fields the copy personalizes on, which is how an email ends up opening with 'Hi ,'. This is a data problem that surfaces as a copy problem.",
|
|
Run: detectMissingPersonalizationData,
|
|
},
|
|
{
|
|
Key: "list_unsubscribed_enrolled",
|
|
Category: models.AdvisorCategoryList,
|
|
About: "Contacts who have unsubscribed but are still enrolled in a campaign. Mailing someone who opted out is the fastest route to a complaint and, in several jurisdictions, is not merely impolite.",
|
|
Run: detectUnsubscribedEnrolled,
|
|
},
|
|
}
|
|
}
|
|
|
|
// campaignsWithLists pairs each non-draft campaign with its list stats, skipping
|
|
// audiences too small for a share to mean anything.
|
|
func campaignsWithLists(s *repository.AdvisorSnapshot, minSize int) []struct {
|
|
Campaign repository.AdvisorCampaign
|
|
List repository.AdvisorListStats
|
|
} {
|
|
out := []struct {
|
|
Campaign repository.AdvisorCampaign
|
|
List repository.AdvisorListStats
|
|
}{}
|
|
for _, c := range s.Campaigns {
|
|
if c.Status == "draft" {
|
|
continue
|
|
}
|
|
l, ok := s.Lists[c.ID]
|
|
if !ok || l.Total < minSize {
|
|
continue
|
|
}
|
|
out = append(out, struct {
|
|
Campaign repository.AdvisorCampaign
|
|
List repository.AdvisorListStats
|
|
}{c, l})
|
|
}
|
|
return out
|
|
}
|
|
|
|
func detectRoleAddresses(s *repository.AdvisorSnapshot) []Finding {
|
|
out := []Finding{}
|
|
for _, cl := range campaignsWithLists(s, 100) {
|
|
r := rate(cl.List.RoleAddresses, cl.List.Total)
|
|
if r < roleAddressShareWarn {
|
|
continue
|
|
}
|
|
|
|
out = append(out, Finding{
|
|
Key: "list_role_addresses",
|
|
GroupTitle: "{count} campaigns are mailing mostly shared inboxes",
|
|
Category: models.AdvisorCategoryList,
|
|
Severity: models.AdvisorMedium,
|
|
Surface: models.AdvisorSurfaceContacts,
|
|
EntityType: "campaign",
|
|
EntityID: ref(cl.Campaign.ID),
|
|
EntityLabel: cl.Campaign.Name,
|
|
Impact: clampImpact(30 + int(r)),
|
|
Title: fmt.Sprintf("%s of %s is shared inboxes", pct(r), cl.Campaign.Name),
|
|
Detail: fmt.Sprintf(
|
|
"%s of the %s in %s are addresses like info@ or sales@. Shared inboxes rarely reply, are usually read by someone with no interest in the offer, and complain at a higher rate than a named recipient does.",
|
|
pct(r), plural(cl.List.Total, "contact", "contacts"), cl.Campaign.Name),
|
|
Remedy: "Filter role addresses out of the list and find the named person instead. A smaller list of real people outperforms a larger one of shared inboxes on every metric that matters.",
|
|
Evidence: map[string]any{
|
|
"campaign": cl.Campaign.Name,
|
|
"role_addresses": cl.List.RoleAddresses,
|
|
"contacts": cl.List.Total,
|
|
"role_share_percent": band(r),
|
|
"reply_rate_percent": band(rate(cl.Campaign.Replied, cl.Campaign.Sent)),
|
|
},
|
|
})
|
|
}
|
|
return out
|
|
}
|
|
|
|
func detectFreeMailHeavy(s *repository.AdvisorSnapshot) []Finding {
|
|
out := []Finding{}
|
|
for _, cl := range campaignsWithLists(s, 100) {
|
|
r := rate(cl.List.FreeMail, cl.List.Total)
|
|
if r < freeMailShareWarn {
|
|
continue
|
|
}
|
|
|
|
out = append(out, Finding{
|
|
Key: "list_free_mail_heavy",
|
|
GroupTitle: "{count} campaigns are mailing mostly consumer mailboxes",
|
|
Category: models.AdvisorCategoryList,
|
|
Severity: models.AdvisorLow,
|
|
Surface: models.AdvisorSurfaceContacts,
|
|
EntityType: "campaign",
|
|
EntityID: ref(cl.Campaign.ID),
|
|
EntityLabel: cl.Campaign.Name,
|
|
Impact: clampImpact(20 + int(r)/2),
|
|
Title: fmt.Sprintf("%s of %s is on consumer mailboxes", pct(r), cl.Campaign.Name),
|
|
Detail: fmt.Sprintf(
|
|
"%s of the contacts in %s are on gmail, outlook.com, yahoo and similar. For B2B outreach that usually means the list was scraped rather than sourced, and consumer providers are also the strictest filters you will face.",
|
|
pct(r), cl.Campaign.Name),
|
|
Remedy: "Check where this list came from. If the target is companies, the addresses should mostly be on company domains.",
|
|
Steps: []string{
|
|
"Check where the list came from. A B2B list that is mostly consumer addresses was usually scraped rather than sourced.",
|
|
"Filter the consumer-domain contacts out and see what is left. If that is most of the list, the list is the problem, not the copy.",
|
|
"Rebuild from a source that gives you company addresses: an export from your CRM, a provider that verifies, or manual research on a smaller set.",
|
|
"Keep the consumer addresses out of cold campaigns. They reply less and complain more, and the complaints land on your sending domain.",
|
|
},
|
|
Evidence: map[string]any{
|
|
"campaign": cl.Campaign.Name,
|
|
"free_mail_contacts": cl.List.FreeMail,
|
|
"contacts": cl.List.Total,
|
|
"free_mail_share_percent": band(r),
|
|
},
|
|
})
|
|
}
|
|
return out
|
|
}
|
|
|
|
func detectSuppressedShare(s *repository.AdvisorSnapshot) []Finding {
|
|
out := []Finding{}
|
|
for _, cl := range campaignsWithLists(s, 50) {
|
|
r := rate(cl.List.Suppressed, cl.List.Total)
|
|
if r < suppressedShareWarn {
|
|
continue
|
|
}
|
|
|
|
out = append(out, Finding{
|
|
Key: "list_suppressed_share",
|
|
GroupTitle: "{count} campaigns have a large share they will never send to",
|
|
Category: models.AdvisorCategoryList,
|
|
Severity: models.AdvisorMedium,
|
|
Surface: models.AdvisorSurfaceContacts,
|
|
EntityType: "campaign",
|
|
EntityID: ref(cl.Campaign.ID),
|
|
EntityLabel: cl.Campaign.Name,
|
|
Impact: clampImpact(25 + int(r)),
|
|
Title: fmt.Sprintf("%s of %s will never be sent to", pct(r), cl.Campaign.Name),
|
|
Detail: fmt.Sprintf(
|
|
"%s of the %s in %s are on your suppression list from a previous bounce, complaint, or unsubscribe. They are skipped at send time, so this campaign will reach far fewer people than its numbers suggest.",
|
|
plural(cl.List.Suppressed, "contact", "contacts"), plural(cl.List.Total, "contact", "contacts"), cl.Campaign.Name),
|
|
Remedy: "Clean the suppressed contacts out of the list so the campaign's reported audience matches what it can actually reach, and check where the list overlaps with ones you have already mailed.",
|
|
Evidence: map[string]any{
|
|
"campaign": cl.Campaign.Name,
|
|
"suppressed": cl.List.Suppressed,
|
|
"contacts": cl.List.Total,
|
|
"suppressed_share_percent": band(r),
|
|
},
|
|
})
|
|
}
|
|
return out
|
|
}
|
|
|
|
func detectMissingPersonalizationData(s *repository.AdvisorSnapshot) []Finding {
|
|
out := []Finding{}
|
|
for _, cl := range campaignsWithLists(s, 50) {
|
|
r := rate(cl.List.MissingFirstName, cl.List.Total)
|
|
if r < missingNameShareWarn {
|
|
continue
|
|
}
|
|
|
|
// Only worth reporting if the copy actually uses the field.
|
|
uses := false
|
|
for _, st := range s.Steps {
|
|
if st.CampaignID != cl.Campaign.ID {
|
|
continue
|
|
}
|
|
if usesFirstName(st.Subject + st.BodyPlain + st.BodyHTML) {
|
|
uses = true
|
|
break
|
|
}
|
|
}
|
|
if !uses {
|
|
continue
|
|
}
|
|
|
|
out = append(out, Finding{
|
|
Key: "list_missing_personalization_data",
|
|
GroupTitle: "{count} campaigns greet contacts that have no first name",
|
|
Category: models.AdvisorCategoryList,
|
|
Severity: models.AdvisorMedium,
|
|
Surface: models.AdvisorSurfaceContacts,
|
|
EntityType: "campaign",
|
|
EntityID: ref(cl.Campaign.ID),
|
|
EntityLabel: cl.Campaign.Name,
|
|
Impact: clampImpact(40 + int(r)),
|
|
Title: fmt.Sprintf("%s of %s has no first name to greet", pct(r), cl.Campaign.Name),
|
|
Detail: fmt.Sprintf(
|
|
"%s greets contacts by first name, but %s in the list have that field empty. Those emails go out with a gap where the name should be, which is the most recognisable tell of automated outreach there is.",
|
|
cl.Campaign.Name, plural(cl.List.MissingFirstName, "contact", "contacts")),
|
|
Remedy: "Give the variable a fallback, or fill the missing names before the campaign reaches those contacts.",
|
|
Steps: []string{
|
|
"The quickest fix is a fallback in the copy. Replace {{.FirstName}} with {{if .FirstName}}{{.FirstName}}{{else}}there{{end}} so the greeting still reads properly when the field is empty.",
|
|
"The better fix is the data. Open Contacts, filter the campaign's list to contacts with no first name, and fill them in or remove them.",
|
|
"If you cannot source the names, drop the greeting from this campaign entirely. An email that opens on the reason you are writing beats one that opens on a guessed name.",
|
|
"Preview against one of the contacts that was missing a name before you resume.",
|
|
},
|
|
Evidence: map[string]any{
|
|
"campaign": cl.Campaign.Name,
|
|
"contacts_missing_first_name": cl.List.MissingFirstName,
|
|
"contacts": cl.List.Total,
|
|
"missing_share_percent": band(r),
|
|
},
|
|
})
|
|
}
|
|
return out
|
|
}
|
|
|
|
func detectUnsubscribedEnrolled(s *repository.AdvisorSnapshot) []Finding {
|
|
out := []Finding{}
|
|
for _, cl := range campaignsWithLists(s, 1) {
|
|
if cl.List.Unsubscribed == 0 || cl.Campaign.Status != "active" {
|
|
continue
|
|
}
|
|
|
|
out = append(out, Finding{
|
|
Key: "list_unsubscribed_enrolled",
|
|
GroupTitle: "{count} campaigns still have unsubscribed contacts enrolled",
|
|
Category: models.AdvisorCategoryList,
|
|
Severity: models.AdvisorHigh,
|
|
Surface: models.AdvisorSurfaceContacts,
|
|
EntityType: "campaign",
|
|
EntityID: ref(cl.Campaign.ID),
|
|
EntityLabel: cl.Campaign.Name,
|
|
Impact: clampImpact(55 + cl.List.Unsubscribed),
|
|
Title: fmt.Sprintf("%s who unsubscribed are still in %s", plural(cl.List.Unsubscribed, "contact", "contacts"), cl.Campaign.Name),
|
|
Detail: fmt.Sprintf(
|
|
"%s in %s have unsubscribed but are still enrolled. Mailing someone who opted out is the fastest way to earn a spam complaint, and in several jurisdictions it is not merely impolite.",
|
|
plural(cl.List.Unsubscribed, "contact", "contacts"), cl.Campaign.Name),
|
|
Remedy: "Remove them from the campaign. If they are still receiving mail, that is a routing problem worth understanding before anything else in this campaign.",
|
|
Steps: []string{
|
|
"Open the campaign's contacts and filter to unsubscribed.",
|
|
"Remove them from the campaign. Suppression stops future sends, but leaving them enrolled keeps the campaign reporting an audience it must not mail.",
|
|
"Check whether any of them were sent to after they unsubscribed. If so, stop the campaign: that is a routing problem, and every further send compounds it.",
|
|
"Check where the list came from. Unsubscribed contacts reappearing usually means a re-import overwrote their status.",
|
|
},
|
|
Evidence: map[string]any{
|
|
"campaign": cl.Campaign.Name,
|
|
"unsubscribed": cl.List.Unsubscribed,
|
|
"contacts": cl.List.Total,
|
|
},
|
|
})
|
|
}
|
|
return out
|
|
}
|
|
|
|
// usesFirstName reports whether the copy actually greets people by first name.
|
|
// Warmbly templates are Go templates, so the field is written `.FirstName`
|
|
// (`{{.FirstName}}`, `{{if .FirstName}}`, `{{.FirstName | title}}`) or, for the
|
|
// index form a spaced custom key would take, `"first_name"`. Checking the
|
|
// property rather than one literal spelling keeps this from silently never
|
|
// firing the way a `{{first_name}}` assumption would.
|
|
func usesFirstName(text string) bool {
|
|
for _, form := range []string{".FirstName", `"first_name"`} {
|
|
if indexFold(text, form) >= 0 {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|
|
|
|
// indexFold is a case-insensitive substring search that avoids allocating a
|
|
// lowered copy of every email body on every run.
|
|
func indexFold(haystack, needle string) int {
|
|
n, h := len(needle), len(haystack)
|
|
if n == 0 || n > h {
|
|
return -1
|
|
}
|
|
for i := 0; i+n <= h; i++ {
|
|
match := true
|
|
for j := 0; j < n; j++ {
|
|
a, b := haystack[i+j], needle[j]
|
|
if 'A' <= a && a <= 'Z' {
|
|
a += 'a' - 'A'
|
|
}
|
|
if 'A' <= b && b <= 'Z' {
|
|
b += 'a' - 'A'
|
|
}
|
|
if a != b {
|
|
match = false
|
|
break
|
|
}
|
|
}
|
|
if match {
|
|
return i
|
|
}
|
|
}
|
|
return -1
|
|
}
|