omi icon indicating copy to clipboard operation
omi copied to clipboard

[Bounty proposal] fix(backend): non-macOS signups starve the day-3 re-engagement cohort ($75 proposed)

Open VIxIon0de opened this issue 2 months ago • 2 comments

Following the contribution guide's invitation to propose paid work — @kodjima33, @josancamon19, would a US$75 bounty be appropriate for this? Proposed amount, not an existing award. Fix and tests are already up as #15326.

Symptom

On any day where the desktop signup cohort is larger than one page, eligible macOS users silently never receive the day-3 re-engagement email, and the funnel counts show nothing wrong.

Cause

collect_day3_candidates (backend/utils/email/day3_reengagement.py) queries the coarse platform bucket and leaves the macOS narrowing to the predicate:

query = (
    DAY3_REENGAGEMENT_SIGNUP_COHORT_QUERY.build(
        client.collection('users'),
        {'signup_platform': 'desktop', 'start': window_start, 'end': window_end},
        field_filter_factory=FieldFilter,
    )
    .order_by('signup_platform_at')
    .limit(limit)
)

limit (MAX_USERS_PER_RUN = 500) is applied to the raw stream. Windows and Linux desktop signups are fetched, occupy page slots, and are only then dropped inside evaluate_candidate as not_macos. An eligible macOS signup sorted behind them is never fetched at all.

Why the miss is permanent, and invisible

The job runs once a day (0 15 * * *) over a window exactly one day wide (SEND_WINDOW_START_HOURS = 72, SEND_WINDOW_END_HOURS = 96). A user skipped by one run has aged past SEND_WINDOW_END_HOURS by the next one and is rejected as too_late. There is no second chance.

It is also unobservable: the funnel counters only count rows that arrived. A user who was never fetched appears in no bucket — not sent, not ineligible, not too_late — so the counts stay internally consistent while the cohort quietly shrinks.

Fix

signup_os is the header lowercased by _normalize_platform (backend/database/users.py), and the values that produce the desktop bucket for a Mac are a closed set already declared in the module as MACOS_SIGNUP_OS_VALUES. An indexed in over that set selects exactly the rows evaluate_candidate would keep, so the narrowing can move into the query without changing which users are eligible. evaluate_candidate still re-checks signup_os, so the predicate remains the source of truth and the query is a prefilter that cannot starve it.

The registry's cohort query spec gains signup_os between the signup_platform equality and the signup_platform_at range — the same shape the day-zero conversations query already uses for status — and firestore.indexes.json is regenerated from the registry in the same change.

Three tests in backend/tests/unit/test_day3_reengagement.py; the regression test and the updated selection test both fail against current main.

Failure class

This is FC-raw-page-limit-before-visibility-filter (limit measured in raw store rows rather than rows the caller can actually use), at a new boundary. Here the store query can express the rule, so the fix is to push the filter down rather than to scan with a budget.

PR: #15326

VIxIon0de avatar Sep 21 '26 03:09 VIxIon0de

@kodjima33 @josancamon19 same question as on #15281 — is $75 right here, or would you rather set the amount yourself? I'm happy either way; I'd just like to know whether proposing a number is the process you want.

The fix is up as #15326, approved, and independently verified. It's only waiting on the first-time-contributor workflow gate so CI can run.

VIxIon0de avatar Sep 22 '26 15:09 VIxIon0de

Fixed on main by #15326. The day-3 cohort query filters signup_os before the limit.

aryanorastar avatar Sep 22 '26 16:09 aryanorastar