feat(HNT-2119): add the Redis-guarded discovery process step - #30
Draft
mmiermans wants to merge 1 commit into
Draft
feat(HNT-2119): add the Redis-guarded discovery process step#30mmiermans wants to merge 1 commit into
mmiermans wants to merge 1 commit into
Conversation
mmiermans
force-pushed
the
claude/hnt-2086-process-article
branch
from
July 6, 2026 17:08
fca1ad9 to
90aca3b
Compare
mmiermans
force-pushed
the
claude/hnt-2086-process-discovery
branch
from
July 6, 2026 17:08
40c02b7 to
63b7d5b
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-2119
Add
processDiscovery, the Redis-guarded step that turns onecrawl-article-discoveryjob into discovery events on thearticle-discoveriestopic and follow-oncrawl-articlejobs. It skips a page still within itsinterval_minutes, holds a per-page lock while it lists the page's articles with Zyte, publishes one discovery event per article and context, and enqueues an extraction job for each article not fetched recently.This builds on the discovery handler, the worker helpers that supply
HandlerResultandwithinMinutes, and the redis-state and pubsub packages. See docs/ARCHITECTURE.md in #14 for where the discovery fan-out sits in the system.Implementation decisions
page:fetchmarker before the Zyte call and the publish fan-outsetTimestampwrites the marker under the lock, beforehandleArticleDiscoveryand before any event or job is published, rather than last as the tech spec step order suggestspage:fetchinside the lockpage:lock,withinMinutesis evaluated a second time before crawlingPromise.allruns the per-context event publishes andenqueueUnfetchedArticlesconcurrentlycrawl-articleenqueue is gated byarticle:fetch. The two publish paths are independent, so running them together holds the page lock only as long as the slower of the two, reducing the window another worker can contend for the same page.crawl_idand the default windowenqueueUnfetchedArticleschecksarticle:fetchper URL; each discovered job carries nocorpus_item, a newrandomUUIDcrawl_id, andrefresh_interval_minutesset to the default article fetch TTLarticle:fetchskip so a URL already being crawled is not re-queued. The freshcrawl_idtraces the extraction back to this discovery, and the default window makes the article worker dedup on the same cadence.finallyreleaseLockrejection is caught and logged, not propagatedfinallyand mask the handler's own outcome, which would nack an otherwise successful message and force a needless redelivery.