feat(HNT-2086): add the article discovery handler - #28
Draft
mmiermans wants to merge 1 commit into
Draft
Conversation
mmiermans
force-pushed
the
claude/hnt-2086-article-handler
branch
from
July 6, 2026 17:08
acf5713 to
83f5ad8
Compare
mmiermans
force-pushed
the
claude/hnt-2086-discovery-handler
branch
from
July 6, 2026 17:08
4b7a119 to
21f1545
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Goal
HNT-2111
Add
handleArticleDiscovery, the pure function that extracts a publisher page's article list through Zyte, drops cross-domain and duplicate links, and fans each surviving article into onearticle-discoveriesevent per context. It returns those events plus the unique article URLs the worker will enqueue for extraction.This builds on the article-handler slice by reusing its BigQuery-safe field mappers, together with the shared
zyteandmetricsclients, the per-domain extraction-mode module, the crawl-commongetRegistrableDomainutil, and the crawl domain types. docs/ARCHITECTURE.md under review as #14 shows the discovery flow.Implementation decisions
selectArticlesresolves the page's registrable domain once withgetRegistrableDomainand drops any list item on a different onegetRegistrableDomainusestldts, matching content-monorepo's use of the same library inservers/curated-corpus-apifor registrable-domain logic.source_urlselectArticlesresolves the page domain frommessage.urlandmapToDiscoveryEventsetssource_urltomessage.url, not Zyte's post-redirect URLsource_urlaligned with thecrawl-articlejob that triggered it. A page that did cross-domain redirect would yield zero discoveries, a safe failure surfaced by monitoring rather than bad data.Setof seen URLs keeps the first item per URL and records its 1-based list positionpage_position, an ML feature, so gaps left by cross-domain and duplicate filtering are intentional. Onecrawl-articlejob is enqueued per unique URL and one discovery event is emitted per article and context.mapToDiscoveryEventsetssummaryfrom the list item'sdescriptionarticleListitem'sarticleBodyin its discoverysummary, and that body is empty for about 80 percent of the 8.3M legacysource = 'PAGE'rows inrss_feed_itemsand reaches 500 characters or more for well under 1 percent, so in list extraction it is rarely a full body and makes a weak summary source. Zyte'sarticleListitems also expose a per-itemdescription, the list-page dek written to summarize each link, sosummaryreads fromdescription, and matching the legacy body field would only copy a mostly empty column for comparability.toEventAuthorsandtoEventTimestampfrom #27 map the discovery event's authors andpublished_atauthors.namesubfield, so the identical guards apply and are worth sharing rather than reimplementing.