fix: a sweep follows the drops FC has just authored, not only recent posts (4392)
CI and images / lint (push) Successful in 3s
CI and images / extension-version (push) Successful in 3s
CI and images / frontend-build (push) Successful in 22s
CI and images / backend-lint-and-test (push) Successful in 34s
CI and images / integration (push) Successful in 2m39s
CI and images / sign-extension (push) Successful in 3s
CI and images / build-agent (push) Successful in 6s
CI and images / build-web (push) Successful in 5s
CI and images / smoke-web (push) Canceled after 0s
CI and images / promote (push) Canceled after 0s

#4392's third cause, and the only one of the three about whether a pair is
SCORED AT ALL rather than how well.

A drop's post_date is backdated to its first message, but FC cannot author the
drop until that message has an embedding and the hourly grouper has run. So a
drop created this minute lands wherever its messages were — days or weeks back
in the feed. The sweep only looked at announcements published within twice the
window of NOW, so by the time the drop existed its neighbours were already
outside the horizon, and nothing brought the sweep back to them.

Measured on the live instance: a pair scoring 0.800 with `associations: []`
and an empty queue. The two scoring fixes in the previous commit would not
have helped it, because nothing scored it.

So the sweep now also gathers announcements sitting beside any drop whose
`last_grew_at`/`downloaded_at` is inside the horizon — the drop's own clock
rather than its backdated position. Capped at MAX_RECENT_DROPS so a backfill
authoring thousands at once does not quietly become the full-library rescan
the manual button exists for, and the id set is sorted before the loop because
a sweep visiting posts in a different order each run is one whose failures
cannot be reproduced.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LVjrnpQjRgHdvq95rASoiR
This commit is contained in:
2026-09-24 08:09:09 -04:00
co-authored by Claude Opus 5
parent fd214f3a08
commit 81f23991e9
2 changed files with 110 additions and 3 deletions
+62
View File
@@ -599,3 +599,65 @@ def test_the_creators_own_phrasing_counts_as_a_declaration():
def test_an_unrelated_server_is_still_not_a_declaration():
"""The widened vocabulary must not widen into ordinary prose."""
assert declared_signal("<p>the servers were down all morning</p>") == 0.0
@pytest.mark.asyncio
async def test_a_drop_grouped_today_pulls_in_the_post_that_announced_it(db):
"""#4392's third cause, and the only one of the three about whether a pair
is SCORED AT ALL rather than how.
A drop's `post_date` is backdated to its first message, but FC cannot
author the drop until that message has an embedding and the hourly grouper
has run. So a drop created this minute lands wherever its messages were —
here, ten days back, far outside the sweep's horizon. Keyed only on how
recent the announcement is, the sweep looks straight past the pair and
never comes back to it.
Measured on the live instance: a pair scoring 0.800 with an empty review
queue.
"""
artist, patreon, discord = await _artist_with_channels(db, "lateartist")
now = datetime.now(UTC)
old = now - timedelta(days=10)
teaser = await _teaser(
db, artist, patreon, at=old, body="Full set is on discord.gg/abc",
)
# post_date is backdated; downloaded_at defaults to now, which is when FC
# actually wrote this row.
drop = await _drop(db, artist, discord, at=old + timedelta(hours=1))
settings = await ImportSettings.load(db)
settings.discord_link_enabled = True
await db.commit()
result = await rescan(db)
await db.commit()
assert result["proposed"] == 1, (
"the announcement is 10 days old and the drop was authored today — "
"a sweep keyed only on the announcement's own date never sees it"
)
assoc = (await db.execute(select(PostAssociation))).scalar_one()
assert assoc.announcement_post_id == teaser.id
assert assoc.payload_post_id == drop.id
@pytest.mark.asyncio
async def test_the_sweep_still_ignores_a_drop_nothing_is_near(db):
"""The widened sweep must not become the full-library rescan it replaced.
A drop authored today with no announcement in range proposes nothing."""
artist, patreon, discord = await _artist_with_channels(db, "lonelyartist")
now = datetime.now(UTC)
await _teaser(
db, artist, patreon, at=now - timedelta(days=60),
body="Full set is on discord.gg/abc",
)
await _drop(db, artist, discord, at=now - timedelta(days=10))
settings = await ImportSettings.load(db)
settings.discord_link_enabled = True
await db.commit()
result = await rescan(db)
await db.commit()
assert result["proposed"] == 0
assert (await db.execute(select(PostAssociation))).scalars().all() == []